#include "KzToolBtn.h"
#include "ui_KzToolBtn.h"

KzToolBtn::KzToolBtn(QWidget *parent)
    : KzWidget(parent)
    , ui(new Ui::KzToolBtn)
{
    ui->setupUi(this);
    InitLayout();
    connect(ui->pushButton,&QPushButton::clicked,this,&KzToolBtn::PressPushBtn);
}

KzToolBtn::~KzToolBtn()
{
    delete ui;
}

void KzToolBtn::SetBtnText(const std::string& text) {
    ui->pushButton->setText(QString::fromStdString(text));
}

void KzToolBtn::InitLayout() {
    layout = new QBoxLayout(QBoxLayout::LeftToRight,this);
    layout->addWidget(ui->pushButton,1);
    ui->pushButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    layout->setContentsMargins(0, 0, 0, 0);
    this->setLayout(layout);
}

void KzToolBtn::PressPushBtn(bool checked) {
    emit Clicked(checked,this->tag);
}
